﻿using DevExpress.XtraBars.Alerter;
using System;

namespace DevExpress.Alert
{
    public partial class FormMain : DevExpress.XtraEditors.XtraForm
    {
        public FormMain()
        {
            InitializeComponent();
        }

        private void OnAlertClick(object sender, EventArgs e)
        {
            // 设置显示速度
            this.acAlert.FormDisplaySpeed = AlertFormDisplaySpeed.Fast;
            // Alert停留时间(ms)
            this.acAlert.AutoFormDelay = 2000;
            // Alert显示位置
            this.acAlert.FormLocation = AlertFormLocation.BottomRight;
            // 弹出Alert
            this.acAlert.Show(
                owner: this,
                caption: "这是一个警告",
                text: "别惹我，我是危险的人"
            );

            var info = new AlertInfo(caption: "这是一个警告", text: "别惹我，我是危险的人");
            this.acAlert.Show(owner: this, info);
        }

        private void OnAlertHtmlElementMouseClick(object sender, AlertHtmlElementMouseEventArgs e)
        {
            switch (e.ElementId)
            {
                case "yes":
                    // TODO: 添加逻辑
                    // ...
                    break;
                case "unshown":
                    // TODO: 添加逻辑
                    // ...
                    break;
                case "cancel":
                    // TODO: 添加逻辑
                    // ...
                    e.HtmlPopup.Close();
                    break;
                default:
                    break;
            }
        }
    }
}
